/**
 * File Comment: Ita a GUI
 */
package edu.gatech.oad.project.presentation;
//$codepro.audit.disable
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;

/**
 * This class is a panel that allows the user
 * to interact with the GUI to view a patient's
 * information.
 * 
 * @author Group 17
 * @version 1
 */
public class NursePatientInfo extends JPanel {
  
  /**
   * Field driver: holds the Driver connected to the GUI
   */
  private Driver driver;
  
  /**
   * Field textField: patient's name
   */
 private JTextField textField;
 
 /**
  * Field textField_1: patient's sex
  */
 private JTextField textField_1;
 
 /**
  * Field textField_2: patient's age
  */
 private JTextField textField_2;
 
 /**
  * Field textField_3: patient's phone
  */
 private JTextField textField_3;
 
 /**
  * Field textField_4: patient's address
  */
 private JTextField textField_4;
 
 /**
  * Field textField_5: patient's email
  */
 private JTextField textField_5;
 
 /**
  * Field textField_6: patient's pharmacy
  */
 private JTextField textField_6;
 
 /**
  * Field textField_7: patient's insurance
  */
 private JTextField textField_7;
 
 /**
  * Field allergies: patient's allergy information
  */
 private JTextField allergies;
 
 /**
  * Field misc: patient's miscellaneous information
  */
 private JTextField misc;
 
 /**
  * Field btnEdit: edit button
  */
 public JButton btnEdit;
 
 /**
  * Field btnTreatmentRecords: view treatment records button
  */
 public JButton btnTreatmentRecords;
 
 /**
  * Field btnBackToHome: back button
  */
 public JButton btnBackToHome;
 
 /**
  * Field patient: username
  */
 public String patient;
 
 /**
  * Field name: name
  */
 private String name;
 
 /**
  * Field sex: sex
  */
 private String sex;
 
 /**
  * Field age: age
  */
 private String age;
 
 /**
  * Field phone: phone
  */
 private String phone;
 
 /**
  * Field address: address
  */
 private String address;
 
 /**
  * Field email: email
  */
 private String email;
 
 /**
  * Field all: allergies
  */
 private String all;
 
 /**
  * Field insurance: insurance
  */
 private String insurance;
 
 /**
  * Field pharmacy: pharmacy
  */
 private String pharmacy;
 
 /**
  * Field mis: miscellaneous
  */
 private String mis;

 /**
  * Constructor.
  * 
  * @param driver the Driver connected the GUI
  * @param patient the Patient whose information is being displayed
  */
 public NursePatientInfo(Driver driver,String patient) {
   this.driver = driver;
   this.patient = patient;
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[]{74, 0, 0, 0, 0, 0, 0};
  gridBagLayout.rowHeights = new int[]{0, 26, 0, 0, 0, 0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[]{1.0, 1.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
  gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);
  
  JLabel lblPatientMedicalHistory = new JLabel("Patient Information");
  lblPatientMedicalHistory.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
  GridBagConstraints gbc_lblPatientMedicalHistory = new GridBagConstraints();
  gbc_lblPatientMedicalHistory.gridwidth = 5;
  gbc_lblPatientMedicalHistory.insets = new Insets(0, 0, 5, 5);
  gbc_lblPatientMedicalHistory.gridx = 1;
  gbc_lblPatientMedicalHistory.gridy = 0;
  add(lblPatientMedicalHistory, gbc_lblPatientMedicalHistory);
  
  JLabel lblPatientInformation = new JLabel("Name");
  GridBagConstraints gbc_lblPatientInformation = new GridBagConstraints();
  gbc_lblPatientInformation.anchor = GridBagConstraints.EAST;
  gbc_lblPatientInformation.insets = new Insets(0, 0, 5, 5);
  gbc_lblPatientInformation.gridx = 0;
  gbc_lblPatientInformation.gridy = 1;
  add(lblPatientInformation, gbc_lblPatientInformation);
  
  textField = new JTextField(10);
  textField.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      name = textField.getText();
    }
  });
  GridBagConstraints gbc_textField = new GridBagConstraints();
  gbc_textField.gridwidth = 2;
  gbc_textField.insets = new Insets(0, 0, 5, 5);
  gbc_textField.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField.gridx = 1;
  gbc_textField.gridy = 1;
  add(textField, gbc_textField);
  textField.setColumns(10);
  
  JLabel lblSex = new JLabel("Sex");
  GridBagConstraints gbc_lblSex = new GridBagConstraints();
  gbc_lblSex.anchor = GridBagConstraints.EAST;
  gbc_lblSex.insets = new Insets(0, 0, 5, 5);
  gbc_lblSex.gridx = 3;
  gbc_lblSex.gridy = 1;
  add(lblSex, gbc_lblSex);
  
  textField_1 = new JTextField(10);
  textField_1.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      sex = textField_1.getText();
    }
  });
  GridBagConstraints gbc_textField_1 = new GridBagConstraints();
  gbc_textField_1.gridwidth = 2;
  gbc_textField_1.insets = new Insets(0, 0, 5, 0);
  gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_1.gridx = 5;
  gbc_textField_1.gridy = 1;
  add(textField_1, gbc_textField_1);
  textField_1.setColumns(10);
  
  JLabel lblAge = new JLabel("Age");
  GridBagConstraints gbc_lblAge = new GridBagConstraints();
  gbc_lblAge.anchor = GridBagConstraints.EAST;
  gbc_lblAge.insets = new Insets(0, 0, 5, 5);
  gbc_lblAge.gridx = 0;
  gbc_lblAge.gridy = 2;
  add(lblAge, gbc_lblAge);
  
  textField_2 = new JTextField(10);
  textField_2.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      age = textField_2.getText();
    }
  });
  GridBagConstraints gbc_textField_2 = new GridBagConstraints();
  gbc_textField_2.gridwidth = 2;
  gbc_textField_2.insets = new Insets(0, 0, 5, 5);
  gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_2.gridx = 1;
  gbc_textField_2.gridy = 2;
  add(textField_2, gbc_textField_2);
  textField_2.setColumns(10);
  
  JLabel lblPhoneNumber = new JLabel("Phone");
  GridBagConstraints gbc_lblPhoneNumber = new GridBagConstraints();
  gbc_lblPhoneNumber.anchor = GridBagConstraints.EAST;
  gbc_lblPhoneNumber.insets = new Insets(0, 0, 5, 5);
  gbc_lblPhoneNumber.gridx = 3;
  gbc_lblPhoneNumber.gridy = 2;
  add(lblPhoneNumber, gbc_lblPhoneNumber);
  
  textField_3 = new JTextField(10);
  textField_3.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      phone = textField_3.getText();
    }
  });
  GridBagConstraints gbc_textField_3 = new GridBagConstraints();
  gbc_textField_3.gridwidth = 2;
  gbc_textField_3.insets = new Insets(0, 0, 5, 0);
  gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_3.gridx = 5;
  gbc_textField_3.gridy = 2;
  add(textField_3, gbc_textField_3);
  textField_3.setColumns(10);
  
  JLabel lblAddress = new JLabel("Address");
  GridBagConstraints gbc_lblAddress = new GridBagConstraints();
  gbc_lblAddress.anchor = GridBagConstraints.EAST;
  gbc_lblAddress.insets = new Insets(0, 0, 5, 5);
  gbc_lblAddress.gridx = 0;
  gbc_lblAddress.gridy = 3;
  add(lblAddress, gbc_lblAddress);
  
  textField_4 = new JTextField(10);
  textField_4.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      address = textField_4.getText();
    }
  });
  GridBagConstraints gbc_textField_4 = new GridBagConstraints();
  gbc_textField_4.gridwidth = 2;
  gbc_textField_4.insets = new Insets(0, 0, 5, 5);
  gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_4.gridx = 1;
  gbc_textField_4.gridy = 3;
  add(textField_4, gbc_textField_4);
  textField_4.setColumns(10);
  
  JLabel lblEmail = new JLabel("Email");
  GridBagConstraints gbc_lblEmail = new GridBagConstraints();
  gbc_lblEmail.anchor = GridBagConstraints.EAST;
  gbc_lblEmail.insets = new Insets(0, 0, 5, 5);
  gbc_lblEmail.gridx = 3;
  gbc_lblEmail.gridy = 3;
  add(lblEmail, gbc_lblEmail);
  
  textField_5 = new JTextField(10);
  textField_5.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      email = textField_5.getText();
    }
  });
  GridBagConstraints gbc_textField_5 = new GridBagConstraints();
  gbc_textField_5.gridwidth = 2;
  gbc_textField_5.insets = new Insets(0, 0, 5, 0);
  gbc_textField_5.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_5.gridx = 5;
  gbc_textField_5.gridy = 3;
  add(textField_5, gbc_textField_5);
  textField_5.setColumns(10);
  
  JLabel lblAllergies = new JLabel("Allergies");
  GridBagConstraints gbc_lblAllergies = new GridBagConstraints();
  gbc_lblAllergies.anchor = GridBagConstraints.EAST;
  gbc_lblAllergies.insets = new Insets(0, 0, 5, 5);
  gbc_lblAllergies.gridx = 0;
  gbc_lblAllergies.gridy = 4;
  add(lblAllergies, gbc_lblAllergies);
  
  allergies = new JTextField(10);
  allergies.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      all = allergies.getText();
    }
  });
  GridBagConstraints gbc_textPane = new GridBagConstraints();
  gbc_textPane.gridwidth = 6;
  gbc_textPane.insets = new Insets(0, 0, 5, 0);
  gbc_textPane.fill = GridBagConstraints.BOTH;
  gbc_textPane.gridx = 1;
  gbc_textPane.gridy = 4;
  add(allergies, gbc_textPane);
  
  JLabel lblInsuranceCarrier = new JLabel("Insurance Carrier");
  GridBagConstraints gbc_lblInsuranceCarrier = new GridBagConstraints();
  gbc_lblInsuranceCarrier.anchor = GridBagConstraints.EAST;
  gbc_lblInsuranceCarrier.insets = new Insets(0, 0, 5, 5);
  gbc_lblInsuranceCarrier.gridx = 0;
  gbc_lblInsuranceCarrier.gridy = 5;
  add(lblInsuranceCarrier, gbc_lblInsuranceCarrier);
  
  textField_7 = new JTextField(10);
  textField_7.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      insurance = textField_7.getText();
    }
  });
  GridBagConstraints gbc_textField_7 = new GridBagConstraints();
  gbc_textField_7.gridwidth = 2;
  gbc_textField_7.insets = new Insets(0, 0, 5, 5);
  gbc_textField_7.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_7.gridx = 1;
  gbc_textField_7.gridy = 5;
  add(textField_7, gbc_textField_7);
  textField_7.setColumns(10);
  
  JLabel lblPharmacy = new JLabel("Pharmacy");
  GridBagConstraints gbc_lblPharmacy = new GridBagConstraints();
  gbc_lblPharmacy.anchor = GridBagConstraints.EAST;
  gbc_lblPharmacy.insets = new Insets(0, 0, 5, 5);
  gbc_lblPharmacy.gridx = 3;
  gbc_lblPharmacy.gridy = 5;
  add(lblPharmacy, gbc_lblPharmacy);
  
  textField_6 = new JTextField(10);
  textField_6.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      pharmacy = textField_6.getText();
    }
  });
  GridBagConstraints gbc_textField_6 = new GridBagConstraints();
  gbc_textField_6.gridwidth = 2;
  gbc_textField_6.insets = new Insets(0, 0, 5, 0);
  gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_6.gridx = 5;
  gbc_textField_6.gridy = 5;
  add(textField_6, gbc_textField_6);
  textField_6.setColumns(10);
  
  JLabel lblMisc = new JLabel("Misc");
  GridBagConstraints gbc_lblMisc = new GridBagConstraints();
  gbc_lblMisc.anchor = GridBagConstraints.EAST;
  gbc_lblMisc.insets = new Insets(0, 0, 5, 5);
  gbc_lblMisc.gridx = 0;
  gbc_lblMisc.gridy = 6;
  add(lblMisc, gbc_lblMisc);
  
  misc = new JTextField(10);
  misc.addCaretListener(new CaretListener() {
    public void caretUpdate(CaretEvent e) {
      mis = misc.getText();
    }
  });
  GridBagConstraints gbc_textPane_2 = new GridBagConstraints();
  gbc_textPane_2.gridheight = 2;
  gbc_textPane_2.gridwidth = 6;
  gbc_textPane_2.insets = new Insets(0, 0, 5, 0);
  gbc_textPane_2.fill = GridBagConstraints.BOTH;
  gbc_textPane_2.gridx = 1;
  gbc_textPane_2.gridy = 6;
  add(misc, gbc_textPane_2);
  
  btnEdit = new JButton("Edit");
  btnEdit.addActionListener(new ButtonListener1(this));
  GridBagConstraints gbc_btnViewPreviousAppointments = new GridBagConstraints();
  gbc_btnViewPreviousAppointments.gridwidth = 2;
  gbc_btnViewPreviousAppointments.insets = new Insets(0, 0, 0, 5);
  gbc_btnViewPreviousAppointments.gridx = 1;
  gbc_btnViewPreviousAppointments.gridy = 8;
  add(btnEdit, gbc_btnViewPreviousAppointments);
  
  btnTreatmentRecords = new JButton("Treatment Records");
  btnTreatmentRecords.addActionListener(new ButtonListener2(this));
  GridBagConstraints gbc_btnTreatmentRecords = new GridBagConstraints();
  gbc_btnTreatmentRecords.insets = new Insets(0, 0, 0, 5);
  gbc_btnTreatmentRecords.gridwidth = 3;
  gbc_btnTreatmentRecords.gridx = 3;
  gbc_btnTreatmentRecords.gridy = 8;
  add(btnTreatmentRecords, gbc_btnTreatmentRecords);
  
  btnBackToHome = new JButton("Back to Home");
  btnBackToHome.addActionListener(new ButtonListener3(this));
  GridBagConstraints gbc_btnBackToHome = new GridBagConstraints();
  gbc_btnBackToHome.insets = new Insets(0, 0, 0, 5);
  gbc_btnBackToHome.gridwidth = 3;
  gbc_btnBackToHome.gridx = 5;
  gbc_btnBackToHome.gridy = 8;
  add(btnBackToHome, gbc_btnBackToHome);
 } // end constructor method
 
 /**
  * Get the Driver.
  * 
  * @return the Driver connected to the GUI
  */
 public Driver getDriver()
 {
   return this.driver;
 } // end getDriver method
 
 /**
  * Get the name.
  * 
  * @return the patient's name
  */
 public String getName()
 {
   return this.name;
 } // end getName method
 
 /**
  * Get the sex.
  * 
  * @return the patient's sex
  */
 public String getSex()
 {
   return this.sex;
 } // end getSex method
 
 /**
  * Get the age.
  * 
  * @return the patient's age
  */
 public String getAge()
 {
   return this.age;
 } // end getAge method
 
 /**
  * Get the phone.
  * 
  * @return the patient's phone number
  */
 public String getPhone()
 {
   return this.phone;
 } // end getPhone method
 
 /**
  * Get the address.
  * 
  * @return the patient's address
  */
 public String getAddress()
 {
   return this.address;
 } // end getAddress method
 
 /**
  * Get the email.
  * 
  * @return the patient's email
  */
 public String getEmail()
 {
   return this.email;
 } // end getEmail method
 
 /**
  * Get the allergy information.
  * 
  * @return the patient's allergies
  */
 public String getAllergies()
 {
   return this.all;
 } // end getAllergies method
 
 /**
  * Get the insurance.
  * 
  * @return the patient's insurance information
  */
 public String getInsurance()
 {
   return this.insurance;
 } // end getInsurance method
 
 /**
  * Get the pharmacy.
  * 
  * @return the patient's pharmacy
  */
 public String getPharmacy()
 {
   return this.pharmacy;
 } // end getPharmacy method
 
 /**
  * Get the miscellaneous.
  * 
  * @return the patient's miscellaneous information
  */
 public String getMisc()
 {
   return this.mis;
 } // end getMisc method

 /**
  * This private inner class implements ActionListener for btnEdit.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener1 implements ActionListener
 {
   /**
    * Field pi: the NursePatientInfo being used
    */
   private NursePatientInfo pi;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param pi the NursePatientInfo being used
    */
   private ButtonListener1(NursePatientInfo pi)
   {
     this.pi = pi;
     this.driver = pi.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     //call IOConverter to update PatientInfo
     this.pi.btnEdit.setText("Updated");
   } // end actionPerformed method
 } // end ButtonListener1 class
 
 /**
  * This private inner class implements ActionListener for btnTreatmentRecords.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener2 implements ActionListener
 {
   /**
    * Field pi: the NursePatientInfo being used
    */
   private NursePatientInfo pi;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param pi the NursePatientInfo being used
    */
   private ButtonListener2(NursePatientInfo pi)
   {
     this.pi = pi;
     this.driver = pi.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new NursePatientListTR(this.driver,this.pi.getName()));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener2 class
 
 /**
  * This private inner class implements ActionListener for btnBackToHome.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener3 implements ActionListener
 {
   /**
    * Field pi: the NursePatientInfo being used
    */
   private NursePatientInfo pi;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param pi the NursePatientInfo being used
    */
   private ButtonListener3(NursePatientInfo pi)
   {
     this.pi = pi;
     this.driver = pi.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new NurseHome(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener3 class
} // end NursePatientInfo class